#include <stdio.h>
int f(char a)
{
    return (a <= '9' && a >= '0') || (a <= 'f' && a >= 'a') || (a <= 'F' && a >= 'A');
}
int main()
{
    int flag, i, j;
    char str[81], newstr[81];
    long long result = 0;
    i = 0;
    scanf("%s", str);
    while (str[i] != '#')
    {
        i++;
    }
    str[i] = '\0';

    i = j = 0;
    flag = 1;
    while (str[i] != '\0')
    {
        if (f(str[i]))
        {
            newstr[j] = str[i];
            j++;
        }
        else if (str[i] == '-' && j == 0)
        {
            flag = -1;
        }
        i++;
    }
    newstr[j] = '\0';

    for (i = 0; newstr[i] != '\0'; i++)
    {
            if (newstr[i] >= '0' && newstr[i] <= '9')
            {
                result = result * 16 + (newstr[i] - '0');
            }
            else if (newstr[i] >= 'a' && newstr[i] <= 'f')
            {
                result = result * 16 + (newstr[i] - 'a' + 10);
            }
            else if (newstr[i] >= 'A' && newstr[i] <= 'F')
            {
                result = result * 16 + (newstr[i] - 'A' + 10);
            }
    }
    printf("%lld\n", result * flag);
    return 0;
}